package com.css.zfzx.sjcj.modules.hddcDrillHole.repository;

import com.css.zfzx.sjcj.modules.hddcDrillHole.repository.entity.HddcDrillholeEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * @author zyb
 * @date 2020-11-30
 */
public interface HddcDrillholeRepository extends JpaRepository<HddcDrillholeEntity, String> {
    @Query(nativeQuery = true,value="select w.* from hddc_drillhole  w where w.id=?1 and w.is_valid=1")
    HddcDrillholeEntity findbyId(String id);

    @Modifying
    @Query(nativeQuery = true,value = "update hddc_drillhole set qualityinspection_status=:qualityinspection_status ,extends1=:extend1 where uuid=:uuid")
    void updateStatus(@Param("qualityinspection_status") String qualityinspection_status,@Param("extend1") String extend1,@Param("uuid") String uuid);

    @Modifying
    @Query(nativeQuery = true,value = "update hddc_drillhole set qualityinspection_status=:qualityinspection_status ,extends1=:extend1 where id=:id")
    void ztupdateStatus(@Param("qualityinspection_status") String qualityinspection_status,@Param("extend1")  String extend1,@Param("id") String id);

    @Query(nativeQuery = true,value = "select * from hddc_drillhole where is_valid=1 and (qualityinspection_status!=3 or qualityinspection_status is null)")
    List<HddcDrillholeEntity> findByAll();

    List<HddcDrillholeEntity> findByProjectIdAndIsValid(String id, String isValid);

    HddcDrillholeEntity findByUuidAndIsValid(String id, String isValid);
}
